package com.iworkh.spring.beans;

import com.iworkh.spring.beans.bean.entity.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * main类
 *
 * @author: iworkh-沐雨云楼
 * @date: 2019-12-17
 */
public class App {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-bean.xml");

        // Computer computer_thinkpad = (Computer) context.getBean("computer_thinkpad");
        // System.out.println(computer_thinkpad);
        //
        // Computer computer_apple = (Computer) context.getBean("computer_apple");
        // System.out.println(computer_apple);


        // Mouse mouse_xiaomi = (Mouse) context.getBean("mouse_xiaomi");
        // System.out.println(mouse_xiaomi);
        //
        //
        // System.out.println("*********************");
        // Computer computer_singleton1 = (Computer) context.getBean("computer_singleton");
        // Computer computer_singleton2 = (Computer) context.getBean("computer_singleton");
        //
        // System.out.println("computer_singleton结果：" + (computer_singleton1 == computer_singleton2));
        //
        // Computer computer_prototype1 = (Computer) context.getBean("computer_prototype");
        // Computer computer_prototype2 = (Computer) context.getBean("computer_prototype");
        //
        // System.out.println("computer_prototype结果：" + (computer_prototype1 == computer_prototype2));
        //
        // System.out.println("*********************");
        // DataSource dataSource = (DataSource)context.getBean("db_conn");
        // System.out.println(dataSource);

        // System.out.println("*********************");
        // LifeCycleEntity lifeCycleEntity = (LifeCycleEntity)context.getBean("lifeCycleEntity");
        // System.out.println(lifeCycleEntity.getAttr());
        // ((ClassPathXmlApplicationContext) context).close();


        Car carStatic = (Car)context.getBean("carStatic");
        System.out.println(carStatic);


        Car carInstance = (Car)context.getBean("carInstance");
        System.out.println(carInstance);

        Car carFactoryBean = (Car)context.getBean("carFactoryBean");
        System.out.println(carFactoryBean);

    }
}
